# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=sympol
pkgver=0.1.9
pkgrel=15
pkgdesc="A C++ tool to work with symmetric polyhedra"
arch=(loong64 x86_64)
url="http://www.math.uni-rostock.de/~rehn/software/sympol.html"
license=(GPL2)
source=($pkgname-$pkgver::"https://github.com/tremlin/SymPol/archive/v$pkgver.tar.gz"
        cddlib-0.94k.patch
        sympol-fix-headers.patch
        sympol-lrs-071.patch
        sympol-bliss-0.77.patch::https://github.com/tremlin/SymPol/commit/d142539f.patch)
depends=(boost-libs lrs cddlib bliss)
makedepends=(cmake permlib eigen)
sha256sums=('6753b8fb30745b66a0886e125c18b539417afcf62b804799eb220bd5a59ccc37'
            '23f85255ad1acbaf9c63134c6d331e0f3b8d06230a05e3f63e57399863579649'
            'f3ed90e6b9af5dae0728c52ce4bb9107f3040481cac6c08116dbf8c19bfe3971'
            '0aa37a4b87021ed04e02fcdae525dc305a8b0490c98bfb82bba2d9af04ef1d35'
            '4d233123b4ecb31116af6c12a3d82616543597d724503dbe4153bf10753df268')

prepare() {
  cd SymPol-$pkgver
  sed -e '/(external/d' -i CMakeLists.txt # Don't use bundled cddlib and lrslib
  rm -r external/{lrslib*,cddlib*}
  patch -p1 -i ../cddlib-0.94k.patch # Fix build with cddlib 0.94k
  patch -p1 -i ../sympol-fix-headers.patch # Keep headers directory structure
  patch -p0 -i ../sympol-lrs-071.patch # Fix build with lrs 071 (Fedora)
  patch -p1 -i ../sympol-bliss-0.77.patch # Fix build with bliss 0.77
}

build() {
  cmake -B build -S SymPol-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_CXX_FLAGS="${CXXFLAGS} -I/usr/include/lrslib -DMA -DGMP -DBLISS_USE_GMP"
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}
